<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>{% block title %}Local Library{% endblock %}</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- Bootstrap 5 CDN -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Optional: Bootstrap Icons -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">

  <!-- Custom styles (optional) -->
  <style>
    body {
      padding-top: 4.5rem;
    }
    footer {
      margin-top: 4rem;
      padding: 2rem 0;
      border-top: 1px solid #ddd;
    }
  </style>
</head>
<body>

  <!-- Navbar -->
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
    <div class="container">
      <a class="navbar-brand" href="/">📚 LocalLibrary</a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
        <span class="navbar-toggler-icon"></span>
      </button>
      
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav ms-auto">
          <li class="nav-item"><a class="nav-link" href="/">Home</a></li>
          <li class="nav-item"><a class="nav-link" href="/catalog/books/">Books</a></li>
          <li class="nav-item"><a class="nav-link" href="/catalog/authors/">Authors</a></li>
          <!-- 登录状态显示 -->
          {% if user.is_authenticated %}
            <li class="nav-item"><a class="nav-link" href="/accounts/logout/">Logout ({{ user.username }})</a></li>
          {% else %}
            <li class="nav-item"><a class="nav-link" href="/accounts/login/">Login</a></li>
          {% endif %}
        </ul>
      </div>
    </div>
  </nav>

  <!-- Main content -->
  <main class="container">
    {% block content %}
    <!-- 页面内容由子模板注入 -->
    {% endblock %}
  </main>

  <!-- Footer -->
  <footer class="container text-center text-muted">
    <p>&copy; {{ current_year|default:2025 }} LocalLibrary · Built with ❤️ using Django</p>
  </footer>

  <!-- Bootstrap JS (optional) -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>